<?php
$shop = new Shop();
$cart = $shop->getCart();
$user = new User();
$uu = $user->getUserId();

//var_dump($cart);
$pp = 0;
?>
<a href="#" class="dib logo fl png"></a>
<div class="nav_wrap fr">
	<div class="function_wrap">
		<div class="cart_wrap fr">
			<span class="shop f14 png pr">购物车<span class="cart_all_num"><?php echo count($cart);?></span>件</span>
			<div class="carts pa oh none">
				<table class="carts_goods_hovre">
					<?php
					if($user->checkLogin()){
					for($n=0;$n< count($cart);$n++){
						$price = $cart[$n]['product_num']*$cart[$n]['info']['price'];
					?>
					<tr>
						<td><img src="<?php echo $cart[$n]['info']['path']?>" width="50" height="50" alt="" class="fl common_bg"></td>
						<td><span class="f12 word_brake"><?php echo $cart[$n]['info']['name']?></span></td>
						<td><span class="f12 word_brake">x<?php echo $cart[$n]['product_num']?></span></td>
						<td><span class="f12 word_brake">￥<?php echo $price?></span></td>
						<td><a href="#" class="no_url f12 word_brake cart_del">删除</a></td>
						<input type="hidden" class="cart_number" value="<?php echo $cart[$n]['id'];?>">
						<input type="hidden" class="cart_price" value="<?php echo $price;?>">
					</tr>
					<?php $pp+=$price;} ?>
					<tr>
						<td colspan="5">
							<p class="f16 fb tr zoom pt10" style="border-top:solid 1px #ccc;">共 <span class="cart_all_num"><?php echo count($cart);?></span> 件商品    合计：￥<span class="chot cart_money"><?php echo $pp;?></span></p>
							<p><form action="/cart1" method="POST"><input type="submit" class="submit submit_buy fr fb f12" value="去结算"></form></p>	
						</td>
					</tr>
					<?php
					}else{
						echo '请先 <a href="/login/login/server?'.$_SERVER["REQUEST_URI"].'" class="dib no_url f14">登录</a> 再查看购物车哦~';
					}?>
				</table>
			</div>
		</div>
		<div class="fr">
			<?php 
			if(isset($_SESSION['login_mail'])){
				echo "<span class='dib no_url f14'>$_SESSION[login_mail]</span> <a href='' class='dib no_url f14 login_out'>[ 退出 ]</a>&nbsp;&nbsp;&nbsp;<a href='/users/order/$uu[u_id]' class='dib no_url f14'>我的订单&nbsp;&nbsp;&nbsp;</a>";
			}else{
			?>
			<a href="/login/login/server?<?php echo $_SERVER["REQUEST_URI"];?>" class="dib no_url f14">登录</a>&nbsp;|
			<a href="/login/register/server?<?php echo $_SERVER["REQUEST_URI"];?>" class="dib no_url f14">注册</a>
			<?php } ?>
		</div>
		
	</div>
	<div class="nav">
		<ul class="fr">
			<li><a href="/home">首页</a></li>
			<li><a href="/store">在线商店</a></li>
			<li><a href="#">服务与支持</a></li>
			<li><a href="#">联系我们</a></li>
		</ul>
	</div>
</div>
